﻿@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    <h2 class="title">@ViewBag.Title</h2>
    <table>
        @foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit))
        {
            if (prop.HideSurroundingHtml)
            {
                @Html.Editor(prop.PropertyName, prop.TemplateHint)
            }
            else
            {
                <tr>
                    <td>
                        <span class="requiredtag">
                            @(prop.IsRequired && prop.ModelType != typeof(bool) ? "*" : "")
                        </span>
                        @Html.Label(prop.PropertyName, prop.GetDisplayName() + ":", new { @class = "autolabel" })
                    </td>
                    <td>
                        @if (string.IsNullOrEmpty(prop.TemplateHint))
                        {
                            @Html.Editor(prop.PropertyName)
                        }
                        else
                        {
                            @Html.Editor(prop.PropertyName, prop.TemplateHint, prop.AdditionalValues)
                        }
                    </td>
                    <td>
                        @Html.ValidationMessage(prop.PropertyName, new { @class = "errortag" })
                    </td>
                </tr>
            }

        }
        <tr>
            <td></td>
            <td align="center"><input class="submit" type="submit" value="确定" /></td>
            <td></td>
        </tr>
    </table>

}